package org.pub.app.lunch;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ProgressBar;

public class Loading extends Activity {

	// public .. 
	ProgressBar m_PrograssReceive;
	private int tempCount = 0;

	/** Called when the activity is first created. */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.loading);

		m_PrograssReceive = (ProgressBar) findViewById(R.id.ID_PGB_RCVPER);
	}

	Handler Activityhdlr = new Handler() {

		@Override
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			if (tempCount >= 100) {
				Intent intent = new Intent(Loading.this, SearchForm.class);
				startActivityForResult(intent, 10);
				finish();
			} else {
				tempCount++;
				m_PrograssReceive.incrementProgressBy(2);
				setProgress(m_PrograssReceive.getProgress() * 100);
				Activityhdlr.sendEmptyMessageDelayed(0, 100);
			}
		}
	};

	private void StartThread() {
		Activityhdlr.sendEmptyMessage(100);
	}

	@Override
	protected void onStart() {
		super.onStart();

		StartThread();
	}

	@Override
	protected void onResume() {
		super.onResume();

		StartThread();
		// Timer 실행 예제  .. 
		//Redraw.schedule(RedrawTask, 1000);
	}

	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	protected void onStop() {
		super.onStop();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}

	protected void OnActivityResult(int requestCode, int resultCode, Intent data) {

	}
}
